//
// triangIntersection class - Intersect triangles
// Author: Antonio Miranda - Fev 2010
//

#ifndef _S3D_TRIANGINTERSECTION_H_
#define _S3D_TRIANGINTERSECTION_H_

#pragma once

#include <vector>

using namespace std;

class dataIntersect;
class attrElem;

// class triangIntersection
/////////////////////////////////////////////////////////////////////
class triangIntersection
{
public:
  triangIntersection(void);
  ~triangIntersection(void);

  // insert meshes
  void insert (void *_mesh);

  // do intersection
  int  doIntersection (void);

  // temporary report
  void report ( );
  void newreport ( );
  int GetCandidatesNumber();
  void GetCandidates(int* CandidatesArray); 
    // CandidatesArray Format: Elem X of Mesh X intersects Elem X of Mesh X
    // So, size of CandidatesArray is 4*CandidatesNumber*sizeof(int) !!!


private:

  // range tree that, in the first approximation, check intersection
  void *m_globalTree;

  // list of meshes and possible intersected elements
  vector <dataIntersect *> m_data;

  // insert a mesh into range tree
  void insertMeshIntoTree (dataIntersect *_mesh);

  // insert a mesh into range tree and check box intersection
  void insertMeshIntoTreeAndCheck (dataIntersect *_mesh);

  bool checkElemIntersection (dataIntersect *_mesh0, int elem0, 
                              dataIntersect *_mesh1, int elem1);

  // added information about intersected triangles
  void  addTriangleIntesect (attrElem *tri01, attrElem *tri02);



};


#endif

